<js href="__PLUGIN__/ajaxfileupload.js"/>

<script type="text/javascript">
/**
 * ------------------------------------------------------
 * 上传幻灯
 * ------------------------------------------------------
 */
$(function(){
	//异步上传
	$("#banner_new_upload").button().click(function(){
		$.ajaxFileUpload({
			url : BASE + '/admin/ueditor/upload_file?type=Image',
			secureuri : false,
			fileElementId : "banner_new_file",
			dataType : 'json',
			data : {},
			type: 'POST',
			success : function(e) {
				if(e.state=="SUCCESS"){
					var url=WEB_ROOT+e.url;
					$("#banner_new_url").val(url);
					$("#file_preview").html("<img src='"+url+"' height='220' width='350'/>")
				}
				else{
					artError(e.state);
				}
			},
			error:function(d,s,e){
				artError("上传失败!")
			}
		})
	});
	//点击提交
	$("#banner_new_add").button().click(function(){
		var url=$("#banner_new_url").val();
		if(isEmpty(url)){
			artError("请上传图片！");
			return;
		}
		var link=$("#banner_new_link").val();
		var title=$("#banner_new_title").val();
		var belong=$("#banner_new_belong").val();
		var position=$("#banner_new_position").val();
		$("#banner_new_add").button("disable");
		$.post(BASE+"/admin/content/banner_list_oper",{
			"oper":"add","url":url,"link":link,"title":title,"show":1,"belong":belong,"position":position
		},function(e){
			if(e.status==1){
				artSuccess("添加成功！",0,function(){
					location.reload();
				});
			}else{
				artError(e.info);
			}
			$("#banner_new_add").button("enable");
		},"json");
	});
});
</script>

<div id="show_banner_edit" class="main" width="750">
	<div class="main_left">
		<fieldset>
			<legend>{$Think.lang.ADD_BANNER}</legend>
			<div class="title_container">
				<label><span class="title_label">{$Think.lang.UPLOAD_IMAGE}</span><span><input type="file" id="banner_new_file" name="upfile" class="file"/></span></label>
				&nbsp;
				<button id="banner_new_upload">
					{$Think.lang.CLICK_UPLOAD}
				</button>
			</div>
			<div class="title_container file_container">
				<span class="title_label">{$Think.lang.IMAGE_PREVIEW}</span>
				<span id="file_preview">
					{$Think.lang.WAIT_UPLOAD}
				</span>
				<input type="hidden" name="url" id="banner_new_url"/>
			</div>
			<div class="title_container">
				<label><span class="title_label">{$Think.lang.LINK}</span><span><input type="text" name="link" maxlength="100" id="banner_new_link" value=""></span></label>
			</div>
			<div class="title_container">
				<label><span class="title_label">{$Think.lang.IMAGE_TITLE}</span><span><input type="text" name="title" maxlength="100" id="banner_new_title" value=""></span></label>
			</div>
			<div class="title_container">
				<label><span class="title_label">{$Think.lang.IMAGE_POSITION}</span><span><input type="text" name="belong" maxlength="20" id="banner_new_position" value="0"></span></label>
			</div>
			<div class="title_container">
				<label><span class="title_label">{$Think.lang.IMAGE_BELONG}</span><span><input type="text" name="belong" maxlength="20" id="banner_new_belong" value="index"></span></label>
				<span>{$Think.lang.DEFAULT_BELONG}</span>
			</div>
			<div class="title_container">
				<button id="banner_new_add">
					{$Think.lang.ADD_BANNER}
				</button>
			</div>
		</fieldset>	
	</div>
	<div class="main_right">
		{$Think.lang.TIP_H3}
		{$Think.lang.BANNER_NEW_TIP}
	</div>
</div>